import 'package:any_reader/public.dart';

class Article {
  String bookId;
  String catalogId;
  String name;
  String num;
  String type;
  String updateTime;
  String isReptileTool;
  String reptileAddress;
  String content;
  String nextCatalogId;
  String nextCatalogNum;
  String preCatalogId;
  String preCatalogNum;
  int index;
  double pageHeight;

  List<Map<String, Object>> pageOffsets = [];

  Article({
    Key key,
    @required this.bookId,
    @required this.catalogId,
    @required this.name,
    @required this.num,
    @required this.type,
    @required this.updateTime,
    @required this.isReptileTool,
    @required this.reptileAddress,
    @required this.content,
    this.nextCatalogId,
    this.nextCatalogNum,
    this.preCatalogId,
    this.preCatalogNum,
    this.index,
    this.pageHeight,
  });
  factory Article.fromJson(
      {String bookId,
      String catalogId,
      String name,
      String num,
      String type,
      String updateTime,
      String isReptileTool,
      String reptileAddress,
      String content,
      String nextCatalogId,
      String nextCatalogNum,
      String preCatalogId,
      String preCatalogNum,
      int index = 0,
      double pageHeight = 0.0}) {
    return Article(
      bookId: bookId,
      catalogId: catalogId,
      name: name,
      num: num,
      type: type,
      updateTime: updateTime,
      isReptileTool: isReptileTool,
      reptileAddress: reptileAddress,
      content: content,
      nextCatalogId: nextCatalogId,
      nextCatalogNum: nextCatalogNum,
      preCatalogId: preCatalogId,
      preCatalogNum: preCatalogNum,
      index: index,
      pageHeight: pageHeight,
    );
  }

  Article.setContent(String content) {
    this.content = content;
  }

  int get pageCount {
    return pageOffsets.length ?? 0;
  }
}
